import math
import numpy
import matplotlib.pyplot as plt
import scipy.fftpack
data = numpy.loadtxt("text.txt")
fs = 640e6
t = numpy.arange(0, (1 / fs * 12800), 1 / fs)
for index, value in enumerate(data):
        # if value > 127:
        #     data[index] = data[index] - 256

        data[index] += 200 * math.sin( math.pi * 40e6 * t[index])

        data[index] += 200 * math.sin(math.pi * 110e6 * t[index])
        data[index] += 200 * math.sin(math.pi * 130e6 * t[index])

        data[index] += 200 * math.sin(math.pi * 190e6 * t[index])
        data[index] += 200 * math.sin(math.pi * 200e6 * t[index])
        data[index] += 200 * math.sin(math.pi * 210e6 * t[index])

        data[index] += 200 * math.sin(math.pi * 260e6 * t[index])
        data[index] += 200 * math.sin(math.pi * 270e6 * t[index])
        data[index] += 200 * math.sin(math.pi * 290e6 * t[index])
        data[index] += 200 * math.sin(math.pi * 300e6 * t[index])

        data[index] += 200 * math.sin(math.pi * 340e6 * t[index])
        data[index] += 200 * math.sin(math.pi * 350e6 * t[index])
        data[index] += 200 * math.sin(math.pi * 360e6 * t[index])
        data[index] += 200 * math.sin(math.pi * 370e6 * t[index])
        data[index] += 200 * math.sin(math.pi * 380e6 * t[index])

        data[index] += 200 * math.sin(math.pi * 410e6 * t[index])
        data[index] += 200 * math.sin(math.pi * 420e6 * t[index])
        data[index] += 200 * math.sin(math.pi * 430e6 * t[index])
        data[index] += 200 * math.sin(math.pi * 450e6 * t[index])
        data[index] += 200 * math.sin(math.pi * 460e6 * t[index])
        data[index] += 200 * math.sin(math.pi * 470e6 * t[index]) 

        data[index] += 200 * math.sin(math.pi * 490e6 * t[index])
        data[index] += 200 * math.sin(math.pi * 500e6 * t[index])
        data[index] += 200 * math.sin(math.pi * 510e6 * t[index])
        data[index] += 200 * math.sin(math.pi * 520e6 * t[index])
        data[index] += 200 * math.sin(math.pi * 530e6 * t[index])
        data[index] += 200 * math.sin(math.pi * 540e6 * t[index])
        data[index] += 200 * math.sin(math.pi * 550e6 * t[index])

        data[index] += 200 * math.sin(math.pi * 570e6 * t[index])
        data[index] += 200 * math.sin(math.pi * 580e6 * t[index])
        data[index] += 200 * math.sin(math.pi * 590e6 * t[index])
        data[index] += 200 * math.sin(math.pi * 600e6 * t[index])
        data[index] += 200 * math.sin(math.pi * 605e6 * t[index])
        data[index] += 200 * math.sin(math.pi * 610e6 * t[index])
        data[index] += 200 * math.sin(math.pi * 620e6 * t[index])
        data[index] += 200 * math.sin(math.pi * 630e6 * t[index])

# f[5700] = 1e4
# f[5800] = 1e4
# f[5900] = 1e4
# f[6000] = 1e4
# f[6050] = 1e4
# f[6100] = 1e4
# f[6200] = 1e4
# f[6300] = 1e4

# f[12800-400] = 1e4

# f[12800-1100] = 1e4
# f[12800-1300] = 1e4

# f[12800-1900] = 1e4
# f[12800-2000] = 1e4
# f[12800-2100] = 1e4

# f[12800-2600] = 1e4
# f[12800-2700] = 1e4
# f[12800-2900] = 1e4
# f[12800-3000] = 1e4


# f[12800-3400] = 1e4
# f[12800-3500] = 1e4
# f[12800-3600] = 1e4
# f[12800-3700] = 1e4
# f[12800-3800] = 1e4

# f[12800-4100] = 1e4
# f[12800-4200] = 1e4
# f[12800-4300] = 1e4
# f[12800-4500] = 1e4
# f[12800-4600] = 1e4
# f[12800-4700] = 1e4

# f[12800-4900] = 1e4
# f[12800-5000] = 1e4
# f[12800-5100] = 1e4
# f[12800-5200] = 1e4
# f[12800-5300] = 1e4
# f[12800-5400] = 1e4
# f[12800-5500] = 1e4

# f[12800-5700] = 1e4
# f[12800-5800] = 1e4
# f[12800-5900] = 1e4
# f[12800-6000] = 1e4
# f[12800-6050] = 1e4
# f[12800-6100] = 1e4
# f[12800-6200] = 1e4
# f[12800-6300] = 1e4

numpy.savetxt("data_rfi.txt", data)
xn = scipy.fftpack.fft(data)
t = numpy.arange(0, (fs + fs/12799), (fs/12799)) + 1182e6
plt.plot(t, abs(xn/12800))
plt.show()